define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		function get_data_findGoods(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"findgoods": ['+
				'{"id": "001","title": "求购螺丝刀","create_time": "2017/01/01 09:12:00","type_count": 11,"goods_count": 210},'+
				'{"id": "002","title": "求购多用螺丝刀","create_time": "2017/02/03 19:30:10","type_count": 36,"goods_count": 67}]},'+
				'"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//返回信息
		return {
			//求购信息一览
			find_goods: function(key,nPage,order,status,callback,calldone) {
				Http.post({
					method: 'info.findgoods.search',
					key:key,
					pagelimit: 10,
					nPage:nPage,
					order: order,
					status:status
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_findGoods(result).result);
				}, function(e) {

				}, function() {
				    if(calldone)
                    	calldone();
				});
			},
			//删除
			deleteOrder: function(id,callback) {
				Http.post({
					method: 'info.findgoods.delete',
					id:id
				}, function(result) {
					//函数回调
					if(callback)
						callback(result);
				}, function(e) {

				}, function() {

				});
			}


		};

	}

	factory.$inject = ['Http'];
	return app.registerService("Pbuy", factory);
});